package cn.edu.zjut.medlinebackend.service.impl;
import org.springframework.stereotype.Service;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

@Service
public class PythonServiceImpl {
    public void Runpython(String filename){
        try {
            // 使用ProcessBuilder执行Python脚本
            ProcessBuilder processBuilder = new ProcessBuilder("python", "python/test.py",filename);
            Process process = processBuilder.start();
            // 获取Python脚本的输出
            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
            // 等待Python脚本执行完成
            int exitCode = process.waitFor();
            System.out.println("Python脚本退出代码：" + exitCode);
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }
    public void QAsystem(){

    }
}
